package com.iqiyi.pps.epg.core.model.vod;

import com.iqiyi.pps.epg.api.model.web.vod.TVodad;
import com.iqiyi.pps.epg.core.utils.DateTimeUtil;
import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;

/**
 * Created by zhangjing on 2017/10/9.
 */
@Entity
@Table(name = "vod_ad")
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class Vodad {
    public static final int STATUS_IS_DELETE = -1;
    public static final int STATUS_IS_NOT_DELETE = 0;
    private Long id;
    private String name;
    private Integer type;
    private Long fileSize;
    private String fileType;
    private Integer contentType;
    private String address;
    private String picAddress;
    private String opUser;
    private Timestamp opTime;
    private Integer status;
    private Timestamp addTime;
    private Long duration;
    private String remark;

    public TVodad convertThriftModel() {
        TVodad tVodad = new TVodad();
        tVodad.setId(this.id);
        tVodad.setName(this.name);
        tVodad.setType(this.type);
        tVodad.setFileSize(this.fileSize);
        tVodad.setFileType(this.fileType);
        tVodad.setContentType(this.contentType.toString());
        tVodad.setAddress(this.address);
        tVodad.setPicAddress(this.picAddress);
        tVodad.setOpUser(this.opUser);
        tVodad.setOpTime(DateTimeUtil.transLongFormat(this.opTime.getTime()));
        tVodad.setDuration(this.duration + "");
        tVodad.setRemark(this.remark);
        if (StringUtils.isNotBlank(this.address)) {
            String uuid = this.address.substring(this.address.lastIndexOf("/") + 1, this.address.length());
            tVodad.setUuid(uuid);
        }
        return tVodad;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "type")
    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    @Column(name = "file_size")
    public Long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    @Column(name = "file_type")
    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    @Column(name = "content_type")
    public Integer getContentType() {
        return contentType;
    }

    public void setContentType(Integer contentType) {
        this.contentType = contentType;
    }

    @Column(name = "address")
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Column(name = "pic_address")
    public String getPicAddress() {
        return picAddress;
    }

    public void setPicAddress(String picAddress) {
        this.picAddress = picAddress;
    }

    @Column(name = "op_user")
    public String getOpUser() {
        return opUser;
    }

    public void setOpUser(String opUser) {
        this.opUser = opUser;
    }

    @Column(name = "op_time")
    public Timestamp getOpTime() {
        return opTime;
    }

    public void setOpTime(Timestamp opTime) {
        this.opTime = opTime;
    }

    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Column(name = "add_time")
    public Timestamp getAddTime() {
        return addTime;
    }

    public void setAddTime(Timestamp addTime) {
        this.addTime = addTime;
    }

    @Column(name = "duration")
    public Long getDuration() {
        return duration;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
    }

    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
